﻿@{
    Bundle("jquery_validate");
    Bundle("browserStorage");
    Bundle("browserInput");
}

<script type="text/javascript">
    jQuery(document).ready(function () {
        jQuery('@ID("#form")').validate({
            rules: {
                email: {
                    required: true,
                    email: true,
                    remote: {
                        url: '@Url.Action(Loc.Act("CheckEmail"))',
                        type: "post",
                        data: {
                            username: function () {
                                return jQuery('@ID("#txt_email")').val();
                            }
                        }
                    }
                },
                username: {
                    required: true,
                    regex: '@Svc.Config(Par.In("Core").Of("AccountEntity").Name("UsernamePattern"))',
                    remote: {
                        url: '@Url.Action(Loc.Act("CheckUsername"))',
                        type: "post",
                        data: {
                            username: function () {
                                return jQuery('@ID("#txt_username")').val();
                            }
                        }
                    }
                },
                password: {
                    required: true,
                    regex: '@Svc.Config(Par.In("Core").Of("AccountEntity").Name("PasswordPattern"))'
                },
                passwordConfirm: {
                    required: true,
                    equalTo: '@ID("#password")'
                },
                captcha: {
                    required: true
                }
            },
            messages: {
                email: {
                    remote: '@T(Res.Name("EmailUnavailable"))'
                },
                username: {
                    remote: '@T(Res.Name("UsernameUnavailable"))'
                }
            }
        });
        jQuery('@ID("#form")').browserInput({
            key: '@Par.In("UserStorage").Of("Input").Name(ViewID)',
            includes: 'input',
            excludes: 'input[type=password], input[name=captcha]',
            reset: '@((TempData.RestoreStatus() >= 0).ToString().ToLowerInvariant())'
        });
    });
</script>
<form class="common-form" id="@ID("form")" action="@Url.Action(Loc.Act("SignUp").Localized())" method="post">
    <table>
        <tr>
            <td>
                <label>@T(Res.In("Common").Of("Vocab").Name("Email"))</label>
            </td>
            <td>
                <input id="@ID("txt_email")" type="text" name="email" maxlength="100" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Username"))</label>
            </td>
            <td>
                <input id="@ID("txt_username")" type="text" name="username" maxlength="100" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Password"))</label>
            </td>
            <td>
                <input id="@ID("password")" type="password" name="password" maxlength="100" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("PasswordConfirm"))</label>
            </td>
            <td>
                <input type="password" name="passwordConfirm" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Captcha"))</label>
            </td>
            <td>
                <input type="text" name="captcha" />
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td>
                <img src="@Url.Action(Loc.Act("Captcha").Set(new
                {
                    key = "SignUp"
                }))" alt="captcha" />
            </td>
        </tr>
    </table>
    <ul class="bar toolbar">
        <li><button class="button" type="submit">@T(Res.In("Common").Of("Act").Name("Submit"))</button></li>
    </ul>
</form>
